﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.IO;

namespace ZF.BLL
{
    public class SystemConfig
    {
        public string SystemDefaultPage { get { return "/default.aspx"; } }
        public string SystemLoginPage { get { return "/default.aspx"; } }
        public bool HousePubVerify { get { return true; } }


        public string SiteUrl
        {
            get
            {
                return "http://www.ajy168.com";
            }

        }

        public string SiteName
        {
            get
            {
                if (SiteInfo.Instance.IsLocal)
                {
                    return "__";
                }
                else
                    return "安家易168";
            }
        }
        /// <summary>
        /// 许愿需要的积分
        /// </summary>
        public int WishingIntegral { get { return 1; } }


        private int _FSWTIntegral = 5;
        /// <summary>
        /// 风水委托业务查得联系方式扣分
        /// </summary>
        public int FSWTIntegral { get { return _FSWTIntegral; } set { _FSWTIntegral = value; } }
        /// <summary>
        /// 1分钟在线咨询所需的积分
        /// </summary>
        public int ConsultationIntegral { get { return 2; } }
        private string[] _FilterWords = null;
        public string[] FilterWords
        {
            get
            {
                if (_FilterWords == null)
                {
                    var file = AppDomain.CurrentDomain.BaseDirectory + @"\bin\Words.txt"; ;
                    var txt=System.IO.File.ReadAllText(file, Encoding.GetEncoding("gb2312"));
                    _FilterWords = txt.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
                }
                return _FilterWords;
            }
            set
            {
                _FilterWords = value;
            }
        }
        public string ManageDirectory { get; set; }

      

        private int _JFReg = 5;
        /// <summary>
        /// 注册赠送积分
        /// </summary>
        public int JFReg { get { return _JFReg; } set { _JFReg = value; } }
        private BFJF _JFBFJF = new BFJF();
        /// <summary>
        /// 许愿积分
        /// </summary>
        public BFJF JFBFJF { get { return _JFBFJF; } set { _JFBFJF = value; } }
        int _JFRecommend =2;
        /// <summary>
        /// 推荐用户注册赠送积分
        /// </summary>
        public int JFRecommend { get { return _JFRecommend; } set { _JFRecommend = value; } }

        private GetPwdEmail _GetPwdEmail = new GetPwdEmail();
        /// <summary>
        /// 获取密码邮件设置
        /// </summary>
        public GetPwdEmail GetPwdEmail { get { return _GetPwdEmail; } set { GetPwdEmail = value; } }

        private TimeSpan _DefCacheTimeSpan = new TimeSpan(0, 5, 0);
        /// <summary>
        /// 默认缓存时间
        /// </summary>
        public TimeSpan DefCacheTimeSpan { get { return _DefCacheTimeSpan; } set { _DefCacheTimeSpan = value; } }

        private AlipaySet _AlipaySet = new AlipaySet();
        public AlipaySet AlipaySet { get { return _AlipaySet; } set { _AlipaySet = value; } }


        private BConfig _BConfig = new BConfig();
        /// <summary>
        /// 网站底部信息
        /// </summary>
        public BConfig BConfig { get { return _BConfig; } set { _BConfig = value; } }
        

        private string _Domain = "http://www.ajy168.com";
        public string Domain { get { return _Domain; } set { _Domain = value; } }
        /// <summary>
        /// 商品模板
        /// </summary>
        public string ShopTemplate { get; set; }
        public void Save()
        {
            var sysConfigFile = System.Configuration.ConfigurationSettings.AppSettings[AppKey.WebConfigKey.SysConfigFile];
            sysConfigFile = HttpContext.Current.Server.MapPath(sysConfigFile);
            var txt = Newtonsoft.Json.JsonConvert.SerializeObject(this);
            File.SetAttributes(sysConfigFile, FileAttributes.Normal);
            if (File.Exists(sysConfigFile))
            {
                System.IO.File.WriteAllText(sysConfigFile, txt, Encoding.Unicode);
            }
            else
            {
                throw new Exception("未找到配置文件");
            }
        }



    }

    /// <summary>
    /// 网站底部信息
    /// </summary>
    public class BConfig
    {
        /// <summary>
        /// 网站介绍 
        /// </summary>
        public string About { get; set; }
        /// <summary>
        /// 联系我们
        /// </summary>
        public string CUS { get; set; }
        /// <summary>
        /// 征稿启事
        /// </summary>
        public string ZG { get; set; }
        /// <summary>
        /// 人才招聘 
        /// </summary>
        public string Job { get; set; }
        /// <summary>
        /// 加盟合作
        /// </summary>
        public string Cooperation { get; set; }
        /// <summary>
        /// 广告投放 
        /// </summary>
        public string ADS { get; set; }
        /// <summary>
        /// 版权声明
        /// </summary>
        public string Copyright { get; set; }

    }




    public class GetPwdEmail
    {
        /// <summary>
        /// stmp服务器，默认
        /// </summary>
        public string Stmp = "smtp.163.com";
        /// <summary>
        /// stmp帐号
        /// </summary>
        public string Account = "ax_163";
        /// <summary>
        /// stmp密码
        /// </summary>
        public string Pwd = "1812ax";
        /// <summary>
        /// 发送邮件模板
        /// </summary>
        public string MsgTemplate = "{Account}您在{SiteName}的密码为{Pwd}";

        /// <summary>
        /// 用于发送邮件的邮箱
        /// </summary>
        public string Email = "ax_163@163.com";
    }

    public class AlipaySet
    {

        public string Gateway = "https://www.alipay.com/cooperate/gateway.do?";
        public string Service = "create_direct_pay_by_user";
        public string SellerEmail = "dxb2301@163.com";
        public string Key = "on4z5g6zla730hc8eljzw43fjpft7nfd";                    //安全校验码，与partner是一组，获取方式是：用签约时支付宝帐号登陆支付宝网站www.alipay.com，在商家服务我的商家里即可查到。
        public string Partner = "2088302425343680";   

        public string NotifyUrl = " ";
 
        public string ReturnUrl = " ";

    }

    public class BFJF
    {
        /// <summary>
        /// 基础字数
        /// </summary>
        public int BaseZC = 100;
        /// <summary>
        /// 基础积分
        /// </summary>
        public int BaseJF = 1;
        /// <summary>
        /// 递增字数
        /// </summary>
        public int BFDZZC = 100;
        /// <summary>
        /// 递增积分
        /// </summary>
        public int BFDZJF = 1;

    }

}
 
 

 